﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:OMANE.Modules.Indicateurs"
    xmlns:Theme="clr-namespace:OMANE.Common.UI.Theme;assembly=OMANE.Common.UI.Theme"
    xmlns:converters="clr-namespace:OMANE.Modules.Indicateurs.Views.Converters"
	mc:Ignorable="d"
	x:Class="Views.ViewCorrespondance"
	x:Name="UserControl"
	d:DesignWidth="640" d:DesignHeight="480">

    <UserControl.Resources>

        <CollectionViewSource x:Key="CollViewVariablesEntreeEncours" Source="{Binding VariablesEntreeEncours}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Value.chOutil.Format.typeAff.Name"></PropertyGroupDescription>
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>

        <CollectionViewSource x:Key="CollViewVariablesTbleEntree"
                              Source="{Binding VariablesEntreeBase}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Value.chOutil.Format.typeAff.Name"></PropertyGroupDescription>
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>

        <converters:EtatChampsConverter x:Key="EtatChampsConverter" />

    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="7" />
            <ColumnDefinition Width="2*" />
        </Grid.ColumnDefinitions>
        <DockPanel Grid.Column="0">
            <Label Style="{DynamicResource OMANE_labelTitre}" 
                   DockPanel.Dock="Top"
                   Margin="-1,-1,0,0">Champs du fichier source</Label>

            <ListView x:Name="lstVariablesEntreeEncours" 
                      ItemsSource="{Binding Source={StaticResource CollViewVariablesTbleEntree}}"
                      ItemContainerStyle="{DynamicResource VariablesEntreeEncoursItemStyle}"
                      AllowDrop="True"
                      BorderThickness="0,0,0,0">
                <ListView.Resources>
                    <Style x:Key="VariablesEntreeEncoursStyle" TargetType="{x:Type StackPanel}">
                        <Style.Setters>
                            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="VariableStyle_PreviewMouseLeftButtonDown" />
                        </Style.Setters>
                    </Style>
                    <Style x:Key="VariablesEntreeEncoursItemStyle" TargetType="{x:Type ListBoxItem}">
                        <Style.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="{x:Null}" />
                                <Setter Property="BorderBrush" Value="{x:Null}" />
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="{x:Null}" />
                                <Setter Property="BorderBrush" Value="{x:Null}" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </ListView.Resources>
                <ListView.GroupStyle>
                    <GroupStyle ContainerStyle="{StaticResource ListViewOMANE_GroupItemStyle}" />
                </ListView.GroupStyle>
                <ListView.View>
                    <GridView>
                        <GridView.ColumnHeaderContainerStyle>
                            <Style>
                                <Setter Property="FrameworkElement.Visibility" Value="Collapsed" />
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <GridView.Columns>
                            <GridViewColumn Header="A">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel PreviewMouseDown="VariableStyle_PreviewMouseLeftButtonDown" Orientation="Horizontal">
                                            <!--<Image Source="{Binding Value.chOutil.Format.typeAff.Name, Converter={StaticResource TypeNameToIconConverter}}"></Image>-->
                                            <Image Margin="0,0,5,0" Source="{Binding Value.chOutil.Format.typeAff.Name , Converter={StaticResource TypeNameToIconConverter}}"></Image>
                                            <TextBlock FontWeight="Regular" Text="{Binding Key}"></TextBlock>
                                        </StackPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="B">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Command="{Binding  Path=cmdVisualiserChampsEntree}" CommandParameter="{Binding Value}" Height="18" Width="18"></Button>
                                        <!--Source={x:Static VMtxgar:Locator.ViewModelCmdEncoursCorrespStatic},-->
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView.Columns>
                    </GridView>
                </ListView.View>
            </ListView>
        </DockPanel>
        <GridSplitter Background="White" 
                      HorizontalAlignment="Stretch" 
                      Grid.Column="1"
                      BorderThickness="1,0,1,0"
                      BorderBrush="{StaticResource ResourceKey=BrushCouleur1Base}"/>
        <DockPanel Grid.Column="2">
            <Grid MaxHeight="26" DockPanel.Dock="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition Width="25"></ColumnDefinition>
                    <ColumnDefinition Width="25"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Label Style="{DynamicResource OMANE_labelTitre}"
                       Margin="-1,-1,0,0" Grid.Column="0">Champs du modele taux garanti</Label>
                <Theme:OMANEbtn Grid.Column="1" 
                                Width="Auto" 
                                Height="Auto"
                                BorderThickness="0,0,1,1"
                                Style="{StaticResource btnTool_OMANE_V2}"
                                Icon="{Binding Source={x:Static Theme:StandardIcons.BOUTON_PARCOURIR}}"
                                Command="{Binding cmdChargerFichierCorresp}">
                    <Theme:OMANEbtn.ToolTip>
                        <ToolTip>
                            <TextBlock>Charger un modèle de correspondances pour la table d'encours</TextBlock>
                        </ToolTip>
                    </Theme:OMANEbtn.ToolTip>
                </Theme:OMANEbtn>
                <Theme:OMANEbtn Grid.Column="2" 
                                Width="Auto" 
                                Height="Auto"
                                BorderThickness="0,0,0,1"
                                Style="{StaticResource btnTool_OMANE_V2}"
                                Icon="{Binding Source={x:Static Theme:StandardIcons.BOUTON_ENREGISTRER}}"
                                Command="{Binding cmdEnregistrerFichierCorresp}">
                    <Theme:OMANEbtn.ToolTip>
                        <ToolTip>
                            <TextBlock>Enregistrer le modèle actuel de correspondances de la table d'encours</TextBlock>
                        </ToolTip>
                    </Theme:OMANEbtn.ToolTip>
                </Theme:OMANEbtn>
            </Grid>
            <ListView x:Name="lstVariablesAttenduesEncours"
                      AllowDrop="True" 
                      ItemsSource="{Binding Source={StaticResource CollViewVariablesEntreeEncours}}"
                      ItemContainerStyle="{DynamicResource VariablesTbleEncoursStyle}"
                      BorderThickness="0,0,1,0"
                      FontWeight="Regular">
                <ListView.Resources>
                    <Style x:Key="VariablesTbleEncoursStyle" TargetType="{x:Type ListBoxItem}">
                        <Style.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="{x:Null}" />
                                <Setter Property="BorderBrush" Value="{x:Null}" />
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="{x:Null}" />
                                <Setter Property="BorderBrush" Value="{x:Null}" />
                            </Trigger>
                        </Style.Triggers>
                        <Style.Setters>
                            <EventSetter Event="DragDrop.Drop" Handler="VariableAttendueTbleEncours_Drop" />
                        </Style.Setters>
                    </Style>
                </ListView.Resources>
                <ListView.GroupStyle>
                    <GroupStyle ContainerStyle="{StaticResource ListViewOMANE_GroupItemStyle}" />
                </ListView.GroupStyle>
                <ListView.View>
                    <GridView>
                        <GridView.ColumnHeaderContainerStyle>
                            <Style>
                                <Setter Property="UIElement.Visibility" Value="Collapsed" />
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <GridViewColumn>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Button Margin="0,0,2,0" 
                                                Width="20" Height="20" 
                                                Background="{Binding Value.etat,Converter={StaticResource EtatChampsConverter}}" 
                                                BorderBrush="{Binding Value.etat,Converter={StaticResource EtatChampsConverter}}" 
                                                Style="{StaticResource btnCorrespEtat}" />
                                        <!--Source={x:Static VMtxgar:Locator.ViewModelCmdEncoursCorrespStatic},-->
                                        <Button Command="{Binding  Path=cmdEditerCorrespondance}" CommandParameter="{Binding Value}" 
                                                Margin="0,0,2,0" 
                                                Width="20" 
                                                Height="20" 
                                                Background="{StaticResource ResourceKey=BrushBtnCorrespDesc}"
        									    BorderBrush="{StaticResource ResourceKey=BrushBtnCorrespDesc}" 
                                                Style="{StaticResource btnCorresp}" />
                                        <!-- Source={x:Static VMtxgar:Locator.ViewModelCmdEncoursCorrespStatic},-->
                                        <Button Command="{Binding
                                                    Path=cmdSupprimerCorrespondance}" 
                                                    CommandParameter="{Binding Value}" 
                                                Width="20" 
                                                Height="20" 
                                                Background="{StaticResource ResourceKey=BrushBtnCorrespSuppr}"
        									    BorderBrush="{StaticResource ResourceKey=BrushBtnCorrespSuppr}" 
                                                Style="{StaticResource btnCorresp}"/>
                                        <!--Style="{StaticResource btnCorresp}"-->
                                    </StackPanel>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Key}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Value.chOutil.Format.typeAff.Name}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Width="200">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Width="200" Text="{Binding Value.chBDD.Nom}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
        </DockPanel>
    </Grid>
   
</UserControl>